import request from '@/utils/request'
// src/api/version.js
//设置为正文 version_id
export function conversationSetContent (data) {
  return request({
    url: "/api/v1/version/set",
    method: "POST",
    data
  });
}


// 1. 创建章节
export function createVersions (data) {
  // data包含: { volume_id, title, content }
  return request({
    url: "/api/v1/version/create",
    method: "POST",
    data
  });
}

// 2. 删除章节
export function deleteVersions (versionId) {
  return request({
    url: "/api/v1/version/delete",
    method: "POST",
    data: { version_id: versionId }
  });
}

// 3. 编辑章节标题
export function editVersionsTitle (versionId, title) {
  return request({
    url: "/api/v1/version/update/title",
    method: "POST",
    data: {
      version_id: versionId,
      title
    }
  });
}

// 4. 编辑章节内容
export function editVersionsContent (versionId, content) {
  return request({
    url: "/api/v1/version/edit_content",
    method: "POST",
    data: {
      version_id: versionId,
      content
    }
  });
}

// 5. 编辑章节编号
export function editVersionsNumber (versionId, versionNumber) {
  return request({
    url: "/api/v1/version/edit_number",
    method: "POST",
    data: {
      version_id: versionId,
      version_number: versionNumber
    }
  });
}

export function versionUpdate (versionId, title, content) {
  return request({
    url: "/api/v1/version/update",
    method: "POST",
    data: {
      version_id: versionId,
      title: title,
      content: content
    }
  });
}


// 6. 章节排序
export function sortversion (versionId, targetVersionsId, position) {
  return request({
    url: "/api/v1/version/sort",
    method: "POST",
    data: {
      version_id: versionId,
      target_version_id: targetVersionsId,
      position
    }
  });
}

// 7. 获取章节内容
export function getVersionsContent (versionId) {
  return request({
    url: "/api/v1/version/content",
    method: "POST",
    data: { version_id: versionId }
  });
}

// 8. 获取章节列表
export function getVersionsList (chap_id) {
  return request({
    url: "/api/v1/version/list",
    method: "POST",
    data: { chap_id: chap_id }
  });
}
